package com.elepro.shoppingmall.mapper.comment;

import com.elepro.shoppingmall.entity.comments.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Select("select * from comment")
    public List<Comment> getCommentList();

    @Select("select * from comment where goods_id = #{goodsId}")
    public List<Comment> selectCommentListByGoodsId(Long goodsId);

    @Select("select * from comment where reply_comment_id = #{id}")
    public List<Comment> getCommentByReplyCommentId(Long id);

    @Insert("insert into comment(goods_id,user_id,reply_user_id,reply_comment_id,content,time,picture,like_num) values(#{goodsId},#{userId},#{replyUserId},#{replyCommentId},#{content},#{time},#{picture},#{likeNum})")
    @Options(useGeneratedKeys = true,keyColumn = "id")
    public int insertComment(Comment comment);

    @Delete("delete from comment where id = #{id}")
    public int deleteComment(Long id);
}
